﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using EFong.ServicesInterface;
using EFong.BL;

namespace EFong.Services
{
    public class FinanceService : IFinanceService,IService
    {
        #region IFinanceService 成员

        public Contract.ServiceResult<decimal> CustomerSettle(Contract.CustomerSettlement customerSettlement)
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<decimal>(financeBL.CustomerSettle(customerSettlement));
            }
            catch (BusinessException be) { return this.Fail<decimal>(be); }
            catch (Exception e) { return this.Fail<decimal>(e); }
        }

        public Contract.ServiceResult<List<Contract.Order>> GetOrdersByCustomer(Contract.Customer customer)
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.Order>>(financeBL.GetOrdersByCustomer(customer));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.Order>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.Order>>(e); }
        }

        public Contract.ServiceResult UpdateVendorSettlementList(List<Contract.VendorSettlement> vendorSettlementList)
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                financeBL.UpdateVendorSettlementList(vendorSettlementList);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult<List<Contract.Order>> GetVendorOrders()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.Order>>(financeBL.GetVendorOrders());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.Order>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.Order>>(e); }
        }

        public Contract.ServiceResult<List<Contract.VendorSettlement>> GetVendorSettlementByDate(DateTime startDate, DateTime endDate) 
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.VendorSettlement>>(financeBL.GetVendorSettlementByDate(startDate,endDate));
            }
            catch (BusinessException be) { return this.Fail<List<Contract.VendorSettlement>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.VendorSettlement>>(e); }
        }

        public Contract.ServiceResult Transfer(Contract.AccountTransfer accountTransfer)
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                financeBL.Transfer(accountTransfer);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult Payment(Contract.OtherPayment otherPayment)
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                financeBL.Payment(otherPayment);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult<List<Contract.TourPartySettlement>> GetPendingPayTouringParty()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.TourPartySettlement>>(financeBL.GetPendingPayTouringParty());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.TourPartySettlement>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.TourPartySettlement>>(e); }
        }

        public Contract.ServiceResult TourPartyVendorSettlement(Contract.TourPartySettlement settlement, List<Contract.VendorSettlement> payedList, bool isComplete)
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                financeBL.TourPartyVendorSettlement(settlement, payedList, isComplete);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult VendorSettle(Contract.VendorOtherSettlement vendorSettlement)
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                financeBL.VendorSettle(vendorSettlement);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        public Contract.ServiceResult<List<Contract.飞机票支付单>> GetFlightOrder()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.飞机票支付单>>(financeBL.GetFlightOrder());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.飞机票支付单>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.飞机票支付单>>(e); }
        }

        public Contract.ServiceResult<List<Contract.火车票支付单>> GetTicketOrder()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.火车票支付单>>(financeBL.GetTicketOrder());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.火车票支付单>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.火车票支付单>>(e); }
        }

        public Contract.ServiceResult<List<Contract.酒店支付单>> GetHotelOrder()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.酒店支付单>>(financeBL.GetHotelOrder());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.酒店支付单>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.酒店支付单>>(e); }
        }

        public Contract.ServiceResult<List<Contract.其他支付单>> GetOtherOrder()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.其他支付单>>(financeBL.GetOtherOrder());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.其他支付单>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.其他支付单>>(e); }
        }

        public Contract.ServiceResult<List<Contract.自组团支付单>> GetTPOrder()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.自组团支付单>>(financeBL.GetTPOrder());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.自组团支付单>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.自组团支付单>>(e); }
        }

        public Contract.ServiceResult<List<Contract.Order>> GetHotelDiscountVendorOrders()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<List<Contract.Order>>(financeBL.GetHotelDiscountVendorOrders());
            }
            catch (BusinessException be) { return this.Fail<List<Contract.Order>>(be); }
            catch (Exception e) { return this.Fail<List<Contract.Order>>(e); }
        }

        public Contract.ServiceResult<decimal> GetCash()
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                return this.Return<decimal>(financeBL.GetCash());
            }
            catch (BusinessException be) { return this.Fail<decimal>(be); }
            catch (Exception e) { return this.Fail<decimal>(e); }
        }

        public Contract.ServiceResult SetCash(decimal cash)
        {
            try
            {
                FinanceBL financeBL = new FinanceBL();
                financeBL.SetCash(cash);
                return this.Return();
            }
            catch (BusinessException be) { return this.Fail(be); }
            catch (Exception e) { return this.Fail(e); }
        }

        #endregion
    }
}
